﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_zj_add : YuuzleComic.Web.UI.ManagePage
{
    protected string ninfo = "";
    protected YuuzleComic.Model.zj zj = new YuuzleComic.Model.zj();
    YuuzleComic.BLL.zj zjbll = new YuuzleComic.BLL.zj();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["act"] == "edit")
            {
                ninfo = "修改";
                zj = zjbll.GetModel(Convert.ToInt32(Request.QueryString["id"]));
            }
            else
            {
                ninfo = "添加";
            }

            if (Request.QueryString["act"] == "save")
            {
                if (!string.IsNullOrEmpty(Request.Form["id"]) && Request.Form["id"] != "0")
                {
                    zj = zjbll.GetModel(Convert.ToInt32(Request.Form["id"]));
                }
                zj.zjmc=Request.Form["zjmc"];
                zj.tpadd=Request.Form["tpadd"];
                zj.tps = Convert.ToInt32(Request.Form["tps"]);
                zj.cid=Convert.ToInt32(Request.Form["cid"]);
                zj.tpurl = Request.Form["tpurl"];
                if (zj.id == null || zj.id == 0)//如果章节id不存在就添加
	            {
                    zj.isdownload = true;
                    zj.cjitemid = -1;
                    zj.time = DateTime.Now;
                    zjbll.Add(zj);
	            }
                else//否则就修改
                {
                    zjbll.Update(zj);
                }
                Response.Write("<script>alert('成功：" + ninfo + "采集项目成功!现在返回管理');location='zj_manage.asp?comicid=" + Request["comicid"] + "&cjcomicid=" + Request["cjcomicid"] + "'</script>");
                Response.End();
            }
        }
    }
}